package com.spring.bean.demo7;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringDemo7 {
    @Test
    public void demo1 () {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        Bean1 bean1 = (Bean1) applicationContext.getBean("bean1");
        bean1.say();
        applicationContext.close();
    }

    @Test
    public void demo2 () {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        Bean2 bean21 = (Bean2) applicationContext.getBean("bean2");
        Bean2 bean22 = (Bean2) applicationContext.getBean("bean2");
        System.out.println(bean21);
        System.out.println(bean22);
        System.out.println(bean21 == bean22);
    }
}
